<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<base href="../../../" />
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
	</head>
	<body>
		<h1>[name]</h1>

		<p class="desc">A class containing useful utility functions for scene manipulation.</p>


		<h2>Methods</h2>

		<h3>[method:Group createMeshesFromInstancedMesh]( [param:InstancedMesh instancedMesh] )</h3>
		<p>
		instancedMesh -- The instanced mesh.
		</p>
		<p>
		Creates a new group object that contains a new mesh for each instance of the given instanced mesh.
		</p>

		<h3>[method:Group createMeshesFromMultiMaterialMesh]( [param:Mesh mesh] )</h3>
		<p>
		mesh -- A mesh with multiple materials.
		</p>
		<p>
		Converts the given multi-material mesh into an instance of [page:Group] holding for each material a separate mesh.
		</p>

		<h3>[method:Group createMultiMaterialObject]( [param:BufferGeometry geometry], [param:Array materials] )</h3>
		<p>
		geometry -- The geometry for the set of materials. <br />
		materials -- The materials for the object.
		</p>
		<p>
		Creates a new Group that contains a new mesh for each material defined in materials. Beware that this is not the same as an array of materials which defines multiple materials for 1 mesh.<br />
		This is mostly useful for objects that need both a material and a wireframe implementation.
		</p>

    <h3>[method:T reduceVertices]( [param:Object3D object], [param:function func], [param:T initialValue] )</h3>
		<p>
		object -- The object to traverse (uses [page:Object3D.traverseVisible traverseVisible] internally). <br />
		func -- The binary function applied for the reduction. Must have the signature: (value: T, vertex: Vector3): T. <br />
    initialValue -- The value to initialize the reduction with. This is required
    as it also sets the reduction type, which is not required to be Vector3.
		</p>
		<p>
		Akin to Array.prototype.reduce(), but operating on the vertices of all the
		visible descendant objects, in world space. Additionally, it can operate as a
		transform-reduce, returning a different type T than the Vector3 input. This
		can be useful for e.g. fitting a viewing frustum to the scene.
		</p>

		<h3>[method:undefined sortInstancedMesh]( [param:InstancedMesh mesh], [param:Function compareFn] )</h3>
		<p>
		mesh -- InstancedMesh in which instances will be sorted. <br />
		compareFn -- Comparator function defining the sort order.
		</p>
		<p>
		Sorts the instances within an [page:InstancedMesh], according to a user-defined
		callback. The callback will be provided with two arguments, <i>indexA</i>
		and <i>indexB</i>, and must return a numerical value. See
		[link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description Array.prototype.sort]
		for more information on sorting callbacks and their return values.
		</p>
		<p>
		Because of the high performance cost, three.js does not sort
		[page:InstancedMesh] instances automatically. Manually sorting may be
		helpful to improve display of alpha blended materials (back to front),
		and to reduce overdraw in opaque materials (front to back).
		</p>

		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]
		</p>
	</body>
</html>
